package com.uam.core.lk.utils;

import com.google.common.primitives.Longs;
import com.uam.core.lk.utils.encrypt.Algorithm;
import com.uam.core.lk.utils.encrypt.ByteHex;
import com.uam.core.lk.utils.encrypt.SymmetricalEncrypt;

public class LkIdEncryptUtils {

    private static final String KEY =
        "743f412bab13f5addc5e00e2b72738dff1de1fa836ea7125dc89cc146b46e4ca151042281e9d4455a45a2389c0ce3e4437c83d7ee91ccf0";

    public static String encrypt(Long id) {
        return ByteHex.byte2Hex(SymmetricalEncrypt.encrypt(Algorithm.DES, Longs.toByteArray(id), KEY));
    }

    public static Long decrypt(String hexString) {
        return Longs
            .fromByteArray(SymmetricalEncrypt.decrypt(Algorithm.DES, ByteHex.hexString2ByteArray(hexString), KEY));
    }

    private LkIdEncryptUtils() {

    }
}
